package org.charry.lib.config.impl;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.charry.lib.config.Config;
import org.charry.lib.config.ConfigValue;

import org.charry.lib.commons.log.StackUtility;

public class XMLConfig implements Config {
	private static Log log = LogFactory.getLog(XMLConfig.class);
	private Configuration config = null;

	public XMLConfig(final String configFile) {
		try {
			config = new XMLConfiguration("config/" + configFile);
		} catch (ConfigurationException e) {
			StackUtility.logStackTrace(log, e);
		}
	}

	public String getConfig(String itemName) {
		if (config.containsKey(itemName))
			return config.getString(itemName);
		else
			return "";
	}

	public ConfigValue getKonfig(String item) {
		// TODO Auto-generated method stub
		return null;
	}
}
